/**
 * ****************************************************************************
 * $Author: Yegor Chemisov $
 * $Revision: 1.9 $
 * ****************************************************************************
 */

public class PlayerResult implements java.io.Serializable
{
    public static final int NOT_AVIABLE    = -1;
    private String playerName = "";
    private int misses;
    private long time;

    public PlayerResult ()
    {
        playerName = null;
        this.misses = NOT_AVIABLE;
        this.time = NOT_AVIABLE;
    }

    public PlayerResult (int misses, long time)
    {
        playerName = null;
        this.misses = misses;
        this.time = time;
    }

    public int getMisses()
    {
        return misses;
    }

    public void setMisses(int misses)
    {
        this.misses = misses;
    }

    public long getTime()
    {
        return time;
    }

    public int getSeconds()
    {
        return (int) (time / 1000);
    }

    public void setTime(long time)
    {
        this.time = time;
    }

    public String getPlayerName()
    {
        return playerName;
    }

    public void setPlayerName(String playerName)
    {
        this.playerName = playerName;
    }

    /**
     * Compares two player results.
     *
     * @param   anotherPlayer the <code>PlayerResult</code> to be compared.
     * @return  the value <code>0</code> if the argument PlayerResult is equal
     *          to this PlayerResult; a value less than <code>0</code> if this
     *          PlayerResult is less than the PlayerResult argument; and a
     *          value greater than <code>0</code> if this PlayerResult is
     *          greater than the PlayerResult argument.
     */
    public int compareTo(PlayerResult anotherPlayer)
    {
        if (anotherPlayer.misses == NOT_AVIABLE) return 3;
        if (anotherPlayer.misses > this.misses)
            return 2;
        else if (anotherPlayer.misses < this.misses)
            return -2;
        else if (anotherPlayer.time > this.time)
            return 1;
        else if (anotherPlayer.time < this.time)
            return -1;
        else
            return 0;
    }
}
